package cn.liujianbo.example.base.iterator;

import java.util.Iterator;
import java.util.LinkedList;

/**
 * @author 刘建波
 * @date 2021-11-09 10:11
 */
public class TreeNode<E> {
    private E element;

    private LinkedList<TreeNode<E>> childes = new LinkedList<>();

    public E getElement(){
        return element;
    }

    public LinkedList<TreeNode<E>> getChildes(){
        return childes;
    }

    public  Iterator<E> TreeNodeIterator(IteratorStrategy strategy) {
        TreeNode<E> node = this;
        switch (strategy) {
            case DEEP_FIRST:
                Iterator<E> iterator = new Iterator<E>() {
                    private TreeNode<E> parentNode = node;

                    private TreeNode<E> currentNode = node;

                    private int childIndex;

                    @Override
                    public boolean hasNext() {
                        return node != currentNode;
                    }

                    @Override
                    public E next() {

                        return node.getElement();
                    }
                };
                break;
            case BREADTH_FIRST:
                break;
        }
        return null;
    }



    public enum IteratorStrategy{
        DEEP_FIRST,
        BREADTH_FIRST;
    }
}
